<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8" %>
<%@ include file="/common/taglibs.jsp"%>
<html>
	<head>
		<title>企业审核</title>
		<link type="text/css" rel="stylesheet" href="${ctx }/scripts/plugins/smartpaginator/smartpaginator.css" />
		<script type="text/javascript" src="${ctx }/scripts/plugins/smartpaginator/smartpaginator.js"></script>
		<script type="text/javascript" src="${ctx }/scripts/plugins/date/timer.js"></script>
		<script type="text/javascript">
			function searchAuditUsers(currentPage, pageSize){	
				var url = ctx + "/admin/users.html?ajax=true";
				var param = "";
				if(!isUndefined(currentPage) && !isUndefined(pageSize)){
					param += "&currentPage=" + currentPage + "&pageSize=" + pageSize;
				}
				var sf = function (msg) {
					if (msg != null || msg != "") {
						$("#ul").html(msg);
					}else{
						$("#ul").html("很抱歉，暂时没有企业申请注册。");
					}
				};
				ajax(url, param, sf);	
			}

			function auditDept(id){
				var url = ctx + "/auditDept.html?ajax=true";
				var param = "&userId=" + id;
				var sf = function (msg) {
					if (msg == 1 || msg == "1" || msg == "\"1\"") {
						art.dialog.tips("<label class='success'>审核通过，欢迎新企业加入！</label>", 1.5);
						window.location.reload();
					}else{
						art.dialog.tips("<label class='error'>操作失败，请刷新页面重试！</label>", 1.5);
					}
				};
				ajax(url, param, sf);
			}
			
	        $(function () {
	            $('#pageBar').smartpaginator({ 
	                totalrecords: "${fn:length(users) }", 
	                recordsperpage: 10, 
	                length: "${fn:substringBefore(fn:length(users)/10, '.') - 1 }", 
	                next: '下一页', 
	                prev: '上一页', 
	                first: '首页', 
	                last: '尾页', 
	                theme: 'blue', 
	                controlsalways: true, 
	                onchange: function (newPage) {
	                	searchAuditUsers(newPage, 10);
	           		}
	           	});
	        });
    	</script>
	</head>
	<body>
		<div class="container_16">
			<div class="grid_3">
				<ul class="menu">
					<li>
                  		<a title="企业审核" href="${ctx }/admin/users.html" class="img_menu10">企业审核</a>
		       		</li>
				</ul>
			</div>
			<div class="grid_13 omega">
				<div class="content_top">
					<div class="left">
						<img src="${ctx }/images/bind.png" />
					</div>
					<div class="right">
						企业审核
					</div>
					<div id="divTime" class="time">
				        <label id="lblDate"></label>
				        <label id="lblTime"></label>
				     </div>
				</div>
				<div class="content_bottom">
					<p></p>
					<div id="ul">
						<c:choose>
							<c:when test="${fn:length(users) gt 0 }">
								<table class="statis_tab" style="width: 96%;margin-left: 15px;">
									<tr>
										<th width="15%">
											<span>企业名称</span>
										</th>
										<th width="15%">
											<span>企业邮箱</span>
										</th>
										<th>
											<span>企业地址</span>
										</th>
										<th width="10%">
											<span>联系人</span>
										</th>
										<th width="15%">
											<span>联系电话</span>
										</th>
										<th width="15%">
											<span>注册时间</span>
										</th>
										<th width="10%">
											<span>操作</span>
										</th>
									</tr>
							    	<c:forEach var="user" items="${users }">
										<tr>
											<td>
												<label>${user.displayName }</label>
											</td>
											<td>
												<label>${user.email }</label>
											</td>
											<td style="text-align: left;">
												<label>${user.userInfo.deptAddress }</label>
											</td>
											<td>
												<label>${user.userInfo.contact }</label>
											</td>
											<td>
												<label>${user.userInfo.phone }</label>
											</td>
											<td>
												<label><fmt:formatDate value="${user.regTime }" pattern="yyyy-MM-dd" /></label>
											</td>
											<td>
												<a href="javascript:void(0)" onclick="auditDept(${user.id })">等待审核</a>
											</td>
										</tr>
									</c:forEach>	
					    		</table>
								<c:if test="${fn:length(users) gt 10 }">
									<div id="pageBar" style="width: 570px;"></div>
								</c:if>
							</c:when>
							<c:otherwise>
								<div style="margin-left: 30px;margin-bottom: 30px;">
									很抱歉，暂时没有企业申请注册。
								</div>
							</c:otherwise>
						</c:choose>
					</div>	
				</div>
			</div>
		</div>
		<div class="container_16" style="margin-top: 50px;">
			<p></p>
		</div>
	</body>
</html>